package com.bwton.msx.ccb.utils;


import android.content.Context;
import android.os.Handler;
import android.view.View;
import android.widget.Toast;

public class Toaster {

    private static Toast mToast;


    private static Handler mMainHandler;

    public static void init(Context context) {
        mMainHandler = new Handler(context.getMainLooper());
        mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
    }

    public static void show(final String message) {
        mMainHandler.post(new Runnable() {
            @Override
            public void run() {
                View view = mToast.getView();
                mToast.cancel();
                mToast= new Toast(view.getContext());
                mToast.setView(view);
                mToast.setDuration(Toast.LENGTH_SHORT);
                mToast.setText(message);
                mToast.show();
            }
        });
    }
}
